package train48days;

import java.util.Scanner;

public class 反转部分单项链表 {
    static class Node{
        int val;
        Node next;
        public Node(int val){
            this.val=val;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String  nodeValue = sc.nextLine();
        String[] nodes = nodeValue.split(" ");
        Node dummyHead = new Node(-1);
        Node tail = dummyHead;
        for (int i=0;i<n;i++){
            Node node = new Node(Integer.parseInt(nodes[i]));
            tail.next = node;
            tail = node;
        }
        String part = sc.nextLine();
        int left = Integer.parseInt(part.split(" ")[0]);
        int right = Integer.parseInt(part.split(" ")[1]);
        Node newHead = reversePartList(dummyHead.next , left ,right);
        while (newHead!=null){
            System.out.print(newHead.val+" ");
            newHead=newHead.next;
        }
    }

    public static Node reversePartList(Node head, int left, int right) {
        Node dummyHead = new Node(-1);
        dummyHead.next = head;
        Node prev = dummyHead;
        for (int i = 1; i < left; i++) {
            prev = prev.next;
        }
        Node cur = prev.next;
        for (int i = left; i <right ; i++) {
            Node third = cur.next;
            cur.next = third.next;
            third.next = prev.next;
            prev.next = third;
        }
        return dummyHead.next;
    }
}
